{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>订单列表</h5>
        </div>
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">
                    <div class="collapse" id="searchBox">
                        <div class="layui-form layui-form-item">

                            <div class="layui-input-inline">
                                <input type="text"  name="order_num" class="layui-input search" placeholder="订单号"/>
                            </div>

                            <div class="layui-input-inline">
                                <input type="text"  name="hotel_name" class="layui-input search" placeholder="酒店名称"/>
                            </div>

                            <div class="layui-input-inline">
                                <input type="text" name="user_username" class="layui-input search" placeholder="客户姓名" />
                            </div>

                            <div class="layui-input-inline">
                                <input type="text" name="user_phone" class="layui-input search" placeholder="客户手机号" />
                            </div>

                            <div class="layui-input-inline">
                                <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                                <button  class="layui-btn layui-btn-normal" id="empty" lay-submit="" lay-filter="LAY-search">重置</button>
                            </div>
                        </div>
                    </div>
                </div>
                <!--搜索框结束-->
                <!--操作框开始-->
                <div class="col-sm-12">
                    <!--<div class="input-group pull-left" >-->
                        <!--<button class="btn btn-primary" type="button" onclick="wk.href('{:url('add_config')}')">-->
                            <!--<i class="fa fa-plus"></i> 添加配置-->
                        <!--</button>-->
                        <!--<button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">-->
                            <!--<i class="fa fa-wrench"></i> 批量操作 <span class="caret"></span>-->
                        <!--</button>-->
                        <!--<ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">-->
                            <!--<li><a href="javascript:;" class="layuiBtn" data-type="getCheckData"><i class="fa fa-trash-o"></i> 批量删除 </a></li>-->
                            <!--<li><a  href="javascript:;" class="layuiBtn" data-type="usingAll" id="onAll" data-toggle="tooltip" data-original-title="若未勾选默认启用全部" data-placement="auto"><i class="fa fa-check-circle"></i> 批量启用</a></li>-->
                            <!--<li><a  href="javascript:;" class="layuiBtn" data-type="forbiddenAll" id="offAll" data-toggle="tooltip" data-original-title="若未勾选默认禁用全部" data-placement="auto"><i class="fa fa-ban"></i> 批量禁用</a></li>-->
                        <!--</ul>-->
                    <!--</div>-->
                    <div class="input-group pull-right" data-toggle="tooltip" title="" data-original-title="搜索">
                        <button class="btn btn-primary" data-toggle="collapse"
                                data-target="#searchBox" >
                            <i class="glyphicon glyphicon-search"></i>
                        </button>
                    </div>
                </div>
                <!--操作框结束-->
            </div>
            <div class="hr-line-dashed"></div>
            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="demo"></table>
                    <!--订单状态模版-->
                    <script type="text/html" id="odBar">
                        {{# if(d.order_status == 1){ }}
                        未支付
                        {{# } }}
                        {{# if(d.order_status == 2){ }}
                        已支付
                        {{# } }}
                        {{# if(d.order_status == 3){ }}
                        取消订单
                        {{# } }}
                    </script>

                    <!--消费状态模版-->
                    <script type="text/html" id="conBar">
                        {{# if(d.is_consume == 1){ }}
                        未消费
                        {{# } }}
                        {{# if(d.is_consume == 2){ }}
                        已消费
                        {{# } }}
                    </script>

                    <!--押金状态模版-->
                    <script type="text/html" id="casBar">
                        {{# if(d.is_cash == 1){ }}
                        未交
                        {{# } }}
                        {{# if(d.is_cash == 2){ }}
                        已交未退
                        {{# } }}
                        {{# if(d.is_cash == 3){ }}
                        已交已退
                        {{# } }}
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Order/index")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , even: false //开启隔行背景
            , size: 'lg' //小尺寸的表格
            // ,width:100
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 30]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
                {type: 'checkbox', fixed: 'left',}
                , {type:'numbers', width: 80, title: '序号'}
                , {field: 'order_num', width: 120, title: '订单号', align: 'center'}
                , {field: 'h_name', width: '', title: '酒店名称', align: 'center'}
                , {field: 'r_num', width: 80, title: '房间号', align: 'center'}
                , {field: 'user_username', width: 90, title: '客户姓名', align: 'center'}
                , {field: 'user_phone', width: 90, title: '手机号', align: 'center'}
                , {field: 'check_time', width: 110, title: '入住时间', align: 'center'}
                , {field: 'leave_time', width: 110, title: '离店时间', align: 'center'}
                , {field: 'create_time', width: '', title: '创建时间', align: 'center'}
                , {field: 'par_time', width: '', title: '支付时间', align: 'center'}
                , {field: 'pay_price', width: 90, title: '支付金额', align: 'center'}
                , {field: 'cash_price', width: 90, title: '押金金额', align: 'center'}
                , {field: 'order_status', width: 90, title: '订单状态', align: 'center', templet: '#odBar'}
                , {field: 'is_consume', width: 90, title: '消费状态', align: 'center', templet: '#conBar'}
                , {field: 'is_cash', width: 90, title: '押金状态', align: 'center', templet: '#casBar'}
            ]]
        });

        //批量操作
        var $ = layui.$, active = {
            getCheckData: function(){
                //批量删除
                wk.batchDel(getIds(),"{:url('batchDelConfig')}");
            }
            ,forbiddenAll: function(){
                //批量禁用
                wk.batchForbidden(getIds(),2,"{:url('forbiddenConfig')}");
            }
            ,usingAll: function(){
                //批量启用
                wk.usingAll(getIds(),1,"{:url('usingConfig')}");
            }
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>